package src.main.kotlin.day91

import java.awt.Point

/**
 * 操作符重载
 *  [] get
 */

operator fun Point.get(index:Int):Int{
    return when(index){
        0 -> x
        1 -> y
        else ->
            throw IndexOutOfBoundsException("Invalid coordinate $index")
    }
}

fun main() {

    val point = Point(20, 30)
    println(point[10])

}